using System.Web.UI;
using NUnit.Framework;

namespace Crawler.Tests
{
	/// <summary>
	/// Summary description for TestMapper.
	/// </summary>
	[TestFixture]
	public class TestMapper
	{
		Mapper mapper;
	
		[SetUp]
		public void Initialize()
		{
			mapper = new Mapper();
		}

		[Test]
		public void TestCount()
		{
			Assertion.AssertEquals("",0,mapper.Count);
		}

		[Test]
		public void TestAdd()
		{
			IKey key = new Key(@"file:///m:/tc/output/btree.exe");
			mapper.Add(key,"fddsf");
			Assertion.AssertEquals("",1,mapper.Count);
		}

		[Test]
		public void TestGetNext()
		{
			Pair keyAndNonDumpablePair = new Pair(new Key(@"file:///m:/tc/output/btree.exe"), @"e:/testdata/tc/output/btree.exe");
			Pair result;

			mapper.Add(new Key(@"file:///m:/tc/output/btree.exe"),  @"e:/testdata/tc/output/btree.exe");
			Assertion.AssertEquals("",1,mapper.Count);
			result = mapper.GetNext();
			Assertion.AssertEquals("",0,mapper.Count);
			Assertion.Assert(result.First.Equals(keyAndNonDumpablePair.First));
			Assertion.Assert(result.Second.Equals(keyAndNonDumpablePair.Second));
		}

		[Test]
		public void TestGetNextReturnsNullPair()
		{
			Pair keyAndNonDumpablePair = new Pair(Key.NULL_KEY,"");
			Pair result;

			Assertion.AssertEquals("",0,mapper.Count);
			result = mapper.GetNext();
			Assertion.AssertEquals("",0,mapper.Count);
			Assertion.Assert(result.First.Equals(keyAndNonDumpablePair.First));
			Assertion.Assert(result.Second.Equals(keyAndNonDumpablePair.Second));
		}
	}
}
